<?php
Route::group(['middleware' => 'auth:seller'], function (\Illuminate\Routing\Router $router) {
    //用户相关
    $router->group(['prefix' => 'user'], function (\Illuminate\Routing\Router $router) {
        $router->get('', 'UserController@fetchList');
        $router->get('{user}', 'UserController@fetchInfo');
        $router->post('', 'UserController@create');
        $router->post('{user}', 'UserController@update');
        $router->delete('{user}', 'UserController@delete');
        $router->patch('{user}/setStatus', 'UserController@setStatus');
        $router->patch('{user}/resetPassword', 'UserController@resetPassword');
        //充值相关
        $router->post('{user}/topUp',"UserTransactionController@topUp");
        $router->post('{user}/consume',"UserTransactionController@consume");
        $router->get('transaction','UserTransactionController@fetchList');
    });
    //账号相关
    $router->group(['prefix' => 'auth'], function (\Illuminate\Routing\Router $router) {
        $router->get('info', 'AuthController@info');
        $router->patch('changePassword', 'AuthController@changePassword');
        $router->post('logout', 'AuthController@logout');
    });
    //财务相关
    $router->group(['prefix'=>'finance'],function(\Illuminate\Routing\Router $router){
        $router->get('','FinanceController@fetchList');
        $router->post('','FinanceController@create');
        $router->delete('{finance}', 'FinanceController@delete');
        $router->get('fetchType','FinanceController@fetchType');
    });
    //商品相关
    $router->group(['prefix'=>'goods'],function(\Illuminate\Routing\Router $router){
        $router->get('','GoodsController@fetchList');
        $router->post('','GoodsController@create');
        $router->post('{goods}','GoodsController@update');
        $router->get('{goods}','GoodsController@fetchInfo');
        $router->patch('{goods}/setStatus', 'GoodsController@setStatus');
        $router->delete('{goods}', 'GoodsController@delete');
    });
    $router->group(['prefix'=>'goodsType'],function(\Illuminate\Routing\Router $router){
        $router->get('','GoodsTypeController@fetchList');
        $router->get('getSelectTree','GoodsTypeController@fetchSelectTree');
        $router->get('{goods_type}','GoodsTypeController@fetchInfo');
        $router->post('','GoodsTypeController@create');
        $router->post('{goods_type}','GoodsTypeController@update');
        $router->delete('{goods_type}','GoodsTypeController@delete');
        $router->patch('{goods_type}/setStatus', 'GoodsTypeController@setStatus');
    });
    $router->group(['prefix'=>'cart'],function(\Illuminate\Routing\Router $router){
        $router->get('','CartController@index');
        $router->post('','CartController@create');
        $router->patch('{item}','CartController@update');

    });
});
Route::group([], function (\Illuminate\Routing\Router $router) {
    $router->group(['prefix' => 'auth'], function (\Illuminate\Routing\Router $router) {
        $router->post('login', 'AuthController@login');
    });
    $router->get('csrf', function () {
        return success();
    });
    $router->post('/upload','UploadController@index');
});